﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Clients.aspx.cs" Inherits="OperatorClients" MasterPageFile="~/Site.master"  %>

<%@ Register TagName="CreditListControl" Src="~/CreditList.ascx" TagPrefix="uc" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <br />
    <asp:HyperLink ID="OperatorLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оператора</asp:HyperLink>
    →
    <b><asp:Label Font-Bold="true" ID="ClientsLabel" runat="server" Text="Клиенты" ForeColor="Black" ></asp:Label></b>
            <br />
            <br />
     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    DataSourceID="SqlDataSourceClientsList" 
        DataKeyNames="CompanyId" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        onrowdatabound="GridView1_RowDataBound" 
        ondatabinding="GridView1_DataBinding">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="Название" HeaderText="Название" 
                            SortExpression="Название" />
                        <asp:BoundField DataField="Руководитель" HeaderText="Руководитель" 
                            SortExpression="Руководитель" />
                        <asp:BoundField DataField="Организационная форма" 
                            HeaderText="Орг. форма" SortExpression="Организационная форма" />
                        <asp:BoundField DataField="Вид деятельности" HeaderText="Вид деятельности" 
                            SortExpression="Вид деятельности" />
                        <asp:BoundField DataField="Размер" HeaderText="Размер" 
                            SortExpression="Размер" />
                        <asp:BoundField DataField="Дата создания" HeaderText="Дата создания" 
                            SortExpression="Дата создания" />
                        <asp:BoundField DataField="Логин" HeaderText="Логин" 
                            SortExpression="Логин" />
                        <asp:BoundField DataField="CompanyId" HeaderText="CompanyId" 
                            InsertVisible="False" ReadOnly="True" SortExpression="CompanyId" 
                            Visible="False" />
                            <asp:TemplateField>
                            <ItemTemplate>
                            <asp:LinkButton ID="RequestCreditLinkButton" runat="server" OnClick="ClickAddRequestCredit">Добавить заявку на кредит</asp:LinkButton>
                            </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                            <ItemTemplate>
                            <asp:LinkButton ID="ShowAccountsLinkButton" runat="server" OnClick="ClickShowAccounts">Счета</asp:LinkButton>
                            </ItemTemplate>
                            </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceClientsList" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
                    
                    
        
        
        SelectCommand="SELECT Company.CompanyName AS Название, Company.CreationDate AS [Дата создания], OrganizationalForm.Name AS [Организационная форма], Activity.Name AS [Вид деятельности], CompanySize.Name AS Размер, UserProfile.CompanyHead AS Руководитель, aspnet_Users.UserName AS Логин, Company.CompanyId FROM CompanySize INNER JOIN Company ON CompanySize.CompanySizeId = Company.CompanySizeId INNER JOIN UserProfile ON Company.CompanyId = UserProfile.CompanyId INNER JOIN OrganizationalForm ON Company.OrganitionalFormId = OrganizationalForm.CompanyOrganizationalFormId INNER JOIN Activity ON Company.ActivityId = Activity.CompanyActivityId INNER JOIN aspnet_Users ON UserProfile.userId = aspnet_Users.UserId WHERE (UserProfile.OperatotId = @OperatorId)">
                    <SelectParameters>
                        <asp:Parameter Name="OperatorId" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
    <asp:Button ID="AddClient" runat="server" Text="Добавить нового клиента" 
        onclick="AddClient_Click" />
</asp:Content>